package com.thinking.in.spring.bean.definition;

import com.think.in.spring.ioc.overview.domain.User;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

/**
 * @author : zjj
 * @date : 2021/12/28 15:46
 */
public class BeanAliasDemo {

    public static void main(String[] args) {
        BeanFactory beanFactory = new ClassPathXmlApplicationContext("META-INF/bean-definitions-context.xml");

        User xiaomageUser =(User) beanFactory.getBean("xiaomage-user");

        System.out.println("别名获取：" + xiaomageUser);

        User user = (User)beanFactory.getBean("user");
        System.out.println(user);

        System.out.println("别名取的和名称取的是否是同一个对象" + (user == xiaomageUser));

    }
}
